<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>添加计费模型</title>
	<link rel="stylesheet" href="/admin/src/css/layui.css">
	<style>
		.mr10{
			display: inline-block;
		}
		.layui-form-label{
			min-width: 140px;
		}
		.layui-upload{
			margin-left: 50px;
		}
		.layui-input-block textarea{
			width:450px;
		}
		.layui-form-item .layui-input-inline{
			width:400px;
		}
		.layui-upload-list{
			margin-left: 40px;
		}
	</style>
</head>

<body >
	<form class="layui-form " style="margin:20px auto;">
		<div class="layui-form-item">
			<label class="layui-form-label">计费模型标题</label>
			<div class="layui-input-inline">
				<input type="text" name="title" id="title" lay-verify="required" placeholder="请输入计费模型标题" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">计费模型编号</label>
			<div class="layui-input-inline">
				<input type="text" name="billing_mode" id="billing_mode" lay-verify="required" placeholder="请输入计费模型编号" autocomplete="off" class="layui-input">
				<div class="layui-form-mid layui-word-aux">请输入2位的16进制数据 (0000到FFFF)，例如：12A1</div>
			</div>
		</div>
		<div class="layui-form-item">
		    <label class="layui-form-label">是否启用</label>
		    <div class="layui-input-block">
				<input type="radio" name="is_status" value="1" title="是" checked>
				<input type="radio" name="is_status" value="2" title="否">
		    </div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">备注</label>
			<div class="layui-input-inline">
				<input type="text" name="remark" id="remark" lay-verify="required" placeholder="请输入备注" autocomplete="off" class="layui-input">
			</div>
		</div>
		<!--设置每个时间段的收费模式-->
		{volist name='getList' id='item'}
			<div class="layui-form-item">
				<label class="layui-form-label">{$item['title']}费率</label>
				<div class="layui-input-inline">
					<select name="{$item['name']}" id="{$item['name']}" lay-verify="required" lay-search="">
						<option value="" >选择计费费率</option>
						{volist name='modelList' id='modelItem'}
						<option value="{$modelItem['value']}" {$item['value'] == $modelItem['value'] ? 'selected':''} >{$modelItem['title']}</option>
						{/volist}
					</select>
				</div>
			</div>
		{/volist}

	  <div class="layui-form-item">
	    <div class="layui-input-block">
	      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
	    </div>
	  </div>
	</form>
	<script src="/admin/src/layui.js" ></script>
<script>
    layui.use(['form','jquery','upload'], function(){
      var form = layui.form ,
		  layer = layui.layer,
          upload = layui.upload,
		  $= layui.jquery;
      //监听表单提交
      form.on('submit(formDemo)', function(data){
		var getData = data.field;
		//return false;
		$.ajax({
			url: '/admin/billingModel/add/data',
			type: 'POST',
			data:getData,
			success : function (backData) {
				//添加成功
			  if(backData['status'] == 200){
				  layer.msg(backData.message,{time:1200},function(){
					  window.parent.frames.location.href="/admin/billingModel/index"
				  })
				  
			  }else{
				  layer.msg(backData.message);
			  }
			}
		})
        return false;
      });
    });



</script>
</body>
</html>
